package com.szy.mvp_demo.UI;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;

import com.szy.mvp_demo.Adapter.ItemMessageAdapter;
import com.szy.mvp_demo.Entity.MessageListEntity;
import com.szy.mvp_demo.R;
import com.szy.mvp_demo.mvp_p.OnDataSuccedListener;
import com.szy.mvp_demo.mvp_v.IMessageView;
import com.szy.mvp_demo.mvp_p.MessageListPresenter;

import java.util.List;

/**
 * 这是消息列表界面
 */
public class MessageListActivity extends AppCompatActivity implements IMessageView<MessageListEntity> {
    private ListView list;
    private MessageListPresenter presenter;
    private ItemMessageAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message_list);
        initview();
    }

    private void initview() {
        list=findViewById(R.id.list_message);
        adapter = new ItemMessageAdapter(this);
        list.setAdapter(adapter);
        presenter = new MessageListPresenter(getIntent().getIntExtra("type", 0), this);
        presenter.LoadData();
    }

    @Override
    public void upDataView(List<MessageListEntity> data) {
        if (data != null) {
            adapter.setdate(data);
        }
    }
}
